﻿/*
 
Celerity: Sensory Overload
Copright 2012 by Adam Hill, David Gannon, Thomas Tamblyn & Patrick Ytting
Contact: adam.hill@outlook.com
Website: adamhill.org
Licence: MS-Pl Licence
  
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Celerity.World
{
	class CollisionTri
	{
		//    0    - -- +
		//  /   \  |
		// 1 --- 2 +
		public Vector2[] points;
		public float widthOver2;
		public float lengthOver2;
		private float z;

		public CollisionTri(float playerAngle, float z, float playerWidth, float playerLength)
		{
			this.widthOver2 = playerWidth / 2;
			this.lengthOver2 = playerLength / 2;
			this.z = -z;
			points = new Vector2[3] { new Vector2(playerAngle, z - lengthOver2), new Vector2(playerAngle - widthOver2, z + lengthOver2), new Vector2(playerAngle + widthOver2, z + lengthOver2) };
		}

		public void Update(float playerAngle)
		{
			points[0].X = playerAngle;
			points[0].Y = this.z - lengthOver2;
			points[1].X = playerAngle - this.widthOver2;
			points[1].Y = this.z + this.lengthOver2;
			points[2].X = playerAngle + this.widthOver2;
			points[2].Y = this.z + this.lengthOver2;
		}

	}
}
